package net.hvacapp.cmvrfforandroid.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import net.hvacapp.cmvrfforandroid.R;

/**
 * TODO: document your custom view class.
 */
public class ItemSelectionView extends RelativeLayout {
    private RelativeLayout mUserSelectionLl;
    private TextView mTitleTv;
    private ImageView mImageIv;

    public ItemSelectionView(Context context) {
        super(context);
        init(context, 0);
    }

    public ItemSelectionView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, 0);
    }

    public ItemSelectionView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context, defStyle);
    }

    public void setOnClickListener(OnClickListener onClickListener) {
        mUserSelectionLl.setOnClickListener(onClickListener);
    }

    public void setItemEnable(boolean enable) {
        if (enable) {
            mTitleTv.setTextColor(getResources().getColor(R.color.cm_table_title_text_color));
        }
        else {
            mTitleTv.setTextColor(getResources().getColor(R.color.cm_table_detail_text_color));
        }
    }

    public void setTitleString (String title) {
        mTitleTv.setText(title);
    }

    public void setItemSelected (boolean selected) {
        if (selected) {
            mImageIv.setVisibility(VISIBLE);
        }
        else {
            mImageIv.setVisibility(GONE);
        }
    }

    private void init(Context context, int defStyle) {
        LayoutInflater.from(context).inflate(R.layout.one_line_cell_item, this,
                true);
        mTitleTv = (TextView) findViewById(R.id.tv_title);
        mImageIv = (ImageView) findViewById(R.id.iv_selected_mark);
        mUserSelectionLl = (RelativeLayout) findViewById(R.id.ll_one_line_cell);
    }


}
